package cn.taobaoke.restful.controller.agent;

import cn.taobaoke.restful.controller.BaseController;
import cn.taobaoke.restful.domain.AccountsEntity;
import cn.taobaoke.restful.service.AccountsService;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * BalanceController类
 *
 * @author luchuan
 * @doc
 * @date 17/6/1
 */
@RestController
@RequestMapping("/{domain}/{domainId}/api/balance")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AgentBalanceController extends BaseController {

    @GetMapping("/{agentId}/accounts")
    public Result getAccounts(@PathVariable Long domainId, @PathVariable String domain, @PathVariable Long agentId) {
        List<AccountsEntity> accounts = accountsService.getAgentAccounts(agentId, domainId, domain);
        return wrapObj(accounts);
    }

    private final
    @NonNull
    AccountsService accountsService;

    private static Logger logger = LogManager.getLogger(AgentBalanceController.class);
}

